<template>
	<view class="apply-friend ss-flex justify-between align-center ss-p-x-20" style="transform: scaleY(-1);"
		v-if="isFriend">
		<view class="apply-left ss-flex flex-sub">
			<uni-icons type="info-filled" size="30" color="#FA5151"></uni-icons>
			<view class="ss-font-24 ">
				<view>对方回复前，您最多发送三条信息回复</view>
				<view>此用户不是您的好友，当心上当受骗！</view>
			</view>
		</view>
		<view class="apply-right" @click="apply">添加好友</view>
	</view>
</template>

<script setup>
	import {
		computed
	} from 'vue';
	import sheep from '@/sheep';
	import $store from '@/im/store/im';

	const isFriend = computed(() => $store().isFriend)
	const chatInfo = computed(() => $store().chatInfo)


	const apply = async () => {
		uni.showLoading({
			title: '发送请求中'
		});
		const {
			data,
			code
		} = await wx.$app.addFriend({
			to: chatInfo.value.userProfile.userID,
			source: 'AddSource_Type_Web',
			type: wx.TIM.TYPES.SNS_ADD_TYPE_BOTH,
		});
		uni.hideLoading();
		if (data.code === 30539) {
			uni.showToast({
				title: data.message,
				icon: 'none'
			})
		} else {
			uni.showToast({
				title: '添加失败!请稍后再试',
				duration: 1500,
				icon: 'none'
			});
		}
	}
</script>

<style scoped lang="scss">
	view {
		box-sizing: border-box;
	}
	.apply-friend {
		position: fixed;
		left: 20rpx;
		bottom: 20rpx;
		width: calc(100vw - 40rpx);
		height: 106rpx;
		border-radius: 10rpx;
		background: #FFFFFF;
		z-index: 9999;

		.apply-right {
			width: 125rpx;
			height: 50rpx;
			border-radius: 6rpx;
			background: rgba(252, 235, 182, 0.5);
			font-family: PingFang SC;
			font-size: 20rpx;
			line-height: 50rpx;
			text-align: center;
			color: #FFA100;
			margin-left: 68rpx;
		}
	}
</style>